package com.sx.fams.country.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sx.core.BaseDao;
import com.sx.fams.country.dao.ICountryDao;
import com.sx.fams.country.entity.CountryEntity;
import com.sx.fams.country.entity.CountryTaskEntity;
import com.sx.feesunit.exception.SXException;

public class CountryDao extends BaseDao implements ICountryDao {
	private Log log = LogFactory.getLog(this.getClass());
	
	/* (non-Javadoc)
	 * @see com.sx.fams.country.dao.ICountryDao#insertCountryTask(com.sx.fams.country.entity.CountryTaskEntity)
	 */
	public Integer insertCountryTask(CountryTaskEntity cte) {
		Integer id = null;
		try {
			id = super.addInfo(cte,"CountryTask.insertCountryTask");
		} catch (Exception e) {
			log.error("插入关联任务和国家信息失败请查明原因!",e);
		}
		return id;
	}

	/* (non-Javadoc)
	 * @see com.sx.fams.country.dao.ICountryDao#findCoutryInfos(com.sx.fams.country.entity.CountryEntity)
	 */
	public List<CountryEntity> findCoutryInfos(String queryname,CountryEntity country) {
		// TODO Auto-generated method stub
		List<CountryEntity> list = new ArrayList<CountryEntity>();
		try {
			list = super.getSqlMapClient().queryForList(queryname, country);
		} catch (Exception e) {
			// TODO: handle exception
			log.error("获取国家或地区出错",e);
		}
		return list;
	}
	
	/**
	 *获取国家和地区信息数据信息
	 **/
	public String findCountryInfosCounts(String queryname,CountryEntity country) throws Exception{
		String str = "";
		try {
			str = (String)getSqlMapClient().queryForObject(queryname, country);
		} catch (Exception e) {
			log.error("获取国家和地区信息",e);
			throw new SXException(e);
		}
		return str;
	}
	
}
